package org.alvin.i18n.ui;

import com.google.common.collect.Lists;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.LinkedList;

public class FileReplace {

    public static void main(String[] args) throws IOException {
        File file = new File("E:\\zhifuyunlian\\workspace\\charge\\xiaolancharging");
        LinkedList<File> files = Lists.newLinkedList();
        files.add(file);
        while (!files.isEmpty()){
            file =files.removeFirst();
            if(file.isDirectory()){
                for(File f : file.listFiles()){
                    files.add(f);
                }
            }else {
                if(file.getName().endsWith(".java")){
                    byte [] buff = Files.readAllBytes(file.toPath());
                    String content = new String(buff);
                    while(content.contains("log.error(com.xl.i18n.I18nUtils.getString")) {
                        System.out.println(file.getName());
                        content.replace("log.error(com.xl.i18n.I18nUtils.getString(\"daochushujuweikong\"));", "log.error(\"导出数据为空\");");
                    }
                    Files.write(file.toPath(), new String(buff).getBytes());
                }
            }
        }
    }
}
